<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<META content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name=ProgId content=VisualStudio.HTML>
<meta name=Originator content="Microsoft Visual Studio .NET 7.1">
</head>
<body onload="page_Load()">
<INPUT dataSrc="#x" dataFld="v" id="txt"
			 onfocus="this.setCapture();this.select()"
			 onblur="this.releaseCapture()"
			 onchange="alert(event.type)"
			 onlosecapture="status='Event:'+event.type"
			 onkeydown="doNavigation(this)"
			 onclick="doClick(this)"
>
<INPUT type="button" onclick="x.recordset('v')='Dimok 1'">
<BR>
<SELECT id="sel" size="3">
	<OPTION value="1">One</OPTION>
	<OPTION value="2">Two</OPTION>
	<OPTION value="3">Three</OPTION>
	<OPTION value="4">Four</OPTION>
	<OPTION value="5">Five</OPTION>
	<OPTION value="6">Six</OPTION>
</SELECT>

<XML id="x"><RS><R v="Dimok" /></RS></XML>
</body>
</html>
<SCRIPT language="javascript">
function page_Load(){
	//txt.setCapture();
	txt.value = "Dimok";
}
function doClick(txt){
	var el = event.srcElement;
	if( el != txt && el != _sel() ){
		txt.blur();
		setTimeout(function(){el.click()},100);
		return;
	}
	if( el == _sel() && _selIndex() < 0 )_sel().click();
}
function fireOnClick(){
	txt.focus();
	x.recordset("v").value = "Dimon 2";
	txt.blur();
	return;
	var e = document.createEventObject();
	e.keyCode = 65;
	e.debug = true;
	txt.fireEvent("onkeypress",e);
}
function doNavigation(txt){
	switch(event.keyCode){
		case 13:
			if( _sel().selectedIndex >= 0 ){
				txt.value = _selText();
				_sel().value = null;
				setTimeout(function(){fireOnClick()},1000);
				event.keyCode = 101;
			}else event.keyCode = 9;
			event.cancelBubble = true;
			break;
		case 40://Down
			_selIndex('d');
			break;
		case 38://Up
			_selIndex( _selIndex()<0?_sel().length-1 : _selIndex('u'));
			break;
		case 33://Page UP
			slideSelectIndex(_sel(),-_selSize()+1);
			break;
		case 34://Page DOWN
			slideSelectIndex(_sel(),_selSize()-1);
			break;
	}
	// Local
	function slideSelectIndex(sel,directon){
		for( var step=directon>0?-1:1; directon != 0; directon += step )
			if( sel.selectedIndex == 0 && directon < 0 || sel.selectedIndex == sel.length-1 && directon > 0 )break;
			else sel.selectedIndex -= step;
	}
}
function _sel(){return sel}// || (_sel.sel=getChildByAttr(document.body,"flyingselect"))}
function _selIndex(index,noEvent){
	if( index == -1 ){
		//debugger;
	}
	if( typeof(index)!='undefined' && isNaN(index) )return _selIndex(_selIndex()+(index=='u'?-1:1),noEvent);
	var sel = _sel();
	if( arguments.length > 0 && sel.length > 0 ){
		var foo = sel.onchange;
		if( noEvent )sel.onchange = null;
		sel.selectedIndex = index;;
		sel.onchange = foo;
	}
	return sel.selectedIndex;
}
function _selSize(){return _sel().size}
function _selText(){return _selIndex()>=0?_sel()[_selIndex()].text:null}
</SCRIPT>
